package com.lottery.im.module.result.adapter.result.statistics;

import android.support.annotation.Nullable;
import android.view.View;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.lottery.im.R;
import com.lottery.im.api.result.entity.GameHistoryInfo;
import com.lottery.im.view.BallLinearLayout;
import java.util.ArrayList;
import java.util.List;

public class HistoryLotteryAdapter extends BaseQuickAdapter<GameHistoryInfo, BaseViewHolder> {
  private List<String> ballList = new ArrayList<>();
  private List<String> items = new ArrayList<>();
  private int index = 0;

  public HistoryLotteryAdapter(@Nullable List<GameHistoryInfo> data) {
    super(R.layout.item_history_pk_list, data);
    for (int i = 0; i < 10; i++) {
      items.add(i + "");
    }
  }

  public void setIndex(int index) {
    this.index = index;
    notifyDataSetChanged();
  }

  public void setAlpha(List<String> items) {
    this.items = items;
    notifyDataSetChanged();
  }

  @Override protected void convert(BaseViewHolder helper, final GameHistoryInfo item) {
    helper.setText(R.id.tv_history_date, item.getDate());
    helper.setText(R.id.tv_history_sueId, item.getIsSueId());
    helper.getView(R.id.tv_history_he).setVisibility(View.GONE);
    BallLinearLayout ballLayout = helper.getView(R.id.layout_ball);
    if (index == 3) {
      ballList.clear();
      ballList.addAll(item.getLhList());
    } else {
      ballList.clear();
      ballList.addAll(item.getStringStr());
    }
    ballLayout.setData(2, ballList, items, index);
  }
}